<?php
  require_once '../../Helpers/DbHelper.php';
  require_once '../../Controllers/AdminController.php';
  require_once '../../Controllers/UserController.php';
  require_once '../../Controllers/StudentController.php';
  require_once '../../Helpers/PathHelper.php';
  //
  $u = new UserController();
  $u->evaluatePagePermission(UserController::ADMINISTRATOR);
  //
  $c = new AdminController();
  $departmentList = $c->getDepartmentList();
  //
  $id = $_GET['id'];
  $s = new StudentController();
  $sDetails = mysql_fetch_assoc($s->read($id));
  //get yearLevelName
  $yearName = $c->getYearLevelName($sDetails['GradeLevel']);
  //
  if(!empty($_POST))
  {
    $receipt = $_POST['or-number'];
    $paymentAmount = $_POST['payment-amount'];
    $date = date('Y-m-d');
    //
   $c->addPaymentLog($id, $paymentAmount, $receipt,$date);
  }
?>
<html>
  <head>
    <title>School Enrolment :: School Fees</title>
    <?php
      require_once '../commons.php';
      renderHeaderStyles() ;
    ?>
  </head>
  <body>
  <div class="admin-container">
    <?php renderAdminNav();?>
  </div>
  <div class="container">
    <h1>Invoice</h1>
    <form name="invoice-form" method="post">
      <table align="center">
        <tr>
          <td><label for="student-number">Student Number: </label></td>
          <td><input type="text" disabled value="<?php echo $sDetails['StudentId']?>" /></td>
        </tr>
        <tr>
          <td><label for="student-name">Name:</label></td>
          <td><input type="text" name="student-name" disabled value="<?php echo $sDetails['Name']?>" /></td>
        </tr>
        <tr>
          <td><label for="year-level">Year Level:</label></td>
          <td><input type="text" disabled value="<?php echo $yearName?>" /></td>
        </tr>
        <tr>
          <td><label for="total-fees">Total Fees:</label></td>
          <td><input type="text" disabled value="<?php echo $sDetails['TotalFees']?>" /></td>
        </tr>
        <tr>
          <td><label for="payment">Payment Amount:</label></td>
          <td><input type="text" name="payment-amount" /></td>
        </tr>
        <tr>
          <td><label for="or-number">OR #:</label></td>
          <td><input type="text" name="or-number" /></td>
        </tr>
        <tr>
          <td><input type="submit" name="submit-payment" value="Submit Form" /></td>
        </tr>
      </table>
    </form>
    <div class="notices"><?php if($message) echo $message ?></div>
  </div>
  </body>
</html>